package pe.edu.upc.jtigers.svpn.data.implement;

import org.springframework.stereotype.Repository;

import pe.edu.upc.jtigers.svpn.aplication.excepcion.DAOExcepcion;
import pe.edu.upc.jtigers.svpn.data.common.BaseDao;
import pe.edu.upc.jtigers.svpn.domain.data.ControlDao;
import pe.edu.upc.jtigers.svpn.domain.model.Control;

@Repository
public class ControlDaoImpl extends BaseDao<Control> implements ControlDao {

	@Override
	public Control registrarControl(Control control) throws DAOExcepcion {
		try {
			if (control.getIdControl() == 0) {
				entityManager.persist(control);
			} else {
				entityManager.merge(control);
			}
		} catch (Exception e) {
			throw new DAOExcepcion(e);
		}
		return control;
	}

}
